<?php
parse_str(implode('&', array_slice($argv, 1)), $_GET);

$tweet_id = isset($_GET['id']) ? urldecode($_GET['id']) : '';
if($tweet_id == ''){
	return '{ "code" : "400" }';
} else {
	$result = remove_tweet($tweet_id);
	print $result;
}

function remove_tweet($tweet_id) {
	$customer_key = isset($_GET['consumer_key']) ? $_GET['consumer_key'] : '';
	$consumer_secret = isset($_GET['consumer_secret']) ? $_GET['consumer_secret'] : '';
	$user_token = isset($_GET['user_token']) ? $_GET['user_token'] : '';
	$user_secret = isset($_GET['user_secret']) ? $_GET['user_secret'] : '';
	if($customer_key == '' or $consumer_secret == '' or $user_token == '' or $user_secret == ''){
		return '{ "code" : "401" }';
	}
	
	require_once('tmhoauth/tmhOAuth.php');
	$connection = new tmhOAuth(array(
		'consumer_key' => $customer_key,
	    'consumer_secret' => $consumer_secret,
	    'user_token' => $user_token,
	    'user_secret' => $user_secret,
	));

	$connection->request('POST', 
	'https://api.twitter.com/1/statuses/destroy/'.$tweet_id.'.json', 
	array(),
	true,
	true
	);
	return '{ "code" : "'.$connection->response['code'].'" , "response" : '.$connection->response['response'].' }';
}
?>

